//
//  ZHButton.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/3/2.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class ZHButton: SWSTAnswerButton {
    
    var zh_color:NSColor = NSColor.white.withAlphaComponent(0.01) {
        didSet {
            self.normalColor = zh_color
            self.highlightColor = zh_color
            self.hoverColor = zh_color
            self.selectedColor = zh_color
        }
    }
    
    var zh_backgroundColor:NSColor = NSColor.clear.withAlphaComponent(0.1) {
        didSet {
            self.backgroundNormalColor = zh_backgroundColor
            self.backgroundHighlightColor = zh_backgroundColor
            self.backgroundSelectedColor = zh_backgroundColor
            let hoverColor = zh_backgroundColor==NSColor.clear ? NSColor.clear:zh_backgroundColor.withAlphaComponent(0.8)
            self.backgroundHoverColor = hoverColor
        }
    }
    
    var zh_borderColor:NSColor = NSColor.init(calibratedRed: 1.0/255, green: 2.0/255, blue: 3.0/255, alpha: 0.01) {
        didSet {
            self.borderNormalColor = zh_borderColor
            self.borderHighlightColor = zh_borderColor
            self.borderHoverColor = zh_borderColor
            self.borderSelectedColor = zh_borderColor
        }
    }
    
    var zh_borderWidth:CGFloat = 1.0 {
        didSet {
            self.borderNormalWidth = zh_borderWidth
            self.borderHighlightWidth = zh_borderWidth
            self.borderHoverWidth = zh_borderWidth
            self.borderSelectedWidth = zh_borderWidth
        }
    }
    
    
    var zh_cornerRadius:CGFloat = 3.0 {
        didSet {
            self.cornerNormalRadius = zh_cornerRadius
            self.cornerHighlightRadius = zh_cornerRadius
            self.cornerHoverRadius = zh_cornerRadius
            self.cornerSelectedRadius = zh_cornerRadius
        }
    }
    
    
    var zh_image:NSImage = NSImage() {
        didSet {
            self.wantsLayer = true
            self.normalImage =  zh_image
            //self.selectedImage = zh_image
        }
    }
    
    var zh_font:NSFont = NSFont.systemFont(ofSize: 12.5) {
        didSet {
            self.wantsLayer = true
            self.font = zh_font
            self.title = zh_title
        }
    }
    
    var zh_title:String = "" {
        didSet {
            self.wantsLayer = true
            self.title = zh_title
            self.font = zh_font
        }
    }
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        self.zh_setupUI()
    }
    
    func zh_setupUI() {
        self.wantsLayer = true
        self.title = ""
        self.font = self.zh_font
        self.zh_color = NSColor.init(calibratedRed: 255.9/256.0, green: 255.9/256.0, blue: 255.9/256.0, alpha: 1.0/1.0)
        self.zh_backgroundColor = NSColor.clear
        self.backgroundHoverColor = NSColor.clear
        self.zh_borderColor = NSColor.clear
        self.zh_borderWidth = 0.0
        self.zh_cornerRadius = 0.0
        self.zh_image = NSImage()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


